Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(debugger): improve output when constrain fails #5

Conversation

anaPerezGhiglia
Copy link
Member

@anaPerezGhiglia anaPerezGhiglia commented Jun 27, 2024

Description

When an assertion fails on Brillig mode, the debugger fails to indicate the user where the program failed

image

while when running on ACIR mode it provides enough information 👇
image

Problem

Resolves

Summary

Context

assert constraints are translated as "jump to trap" if the condition is not met when running in Brillig mode

Changes

  • Add a new field to OpcodeResolutionError::BrilligFunctionFailed to track whether the function failed due to a trap opcode or not
  • Modify BrilligFunctionFailed Display implementation when function failed due to a Trap
    • for doing this I had to remove the usage of Error derive macro, to have a conditional message
    • I decided it was better to have this way rather than just having a new type only for the convenience of the macro
image

Observations

  • TODO: should we return solver ownership in all Err scenarios>?

Documentation

Check one:

  • No documentation needed.
  • Documentation included in this PR.
  • [For Experimental Features] Documentation to be submitted in a separate PR.

PR Checklist

  • I have tested the changes locally.
  • I have formatted the changes with Prettier and/or cargo fmt on default settings.

Copy link

Thank you for your contribution to the Noir language.

Please do not force push to this branch after the Noir team have started review of this PR. Doing so will only delay us merging your PR as we will need to start the review process from scratch.

Thanks for your understanding.

@anaPerezGhiglia anaPerezGhiglia force-pushed the fix/debugger-on-assertion-failure branch from dda35c7 to 54c45a3 Compare June 27, 2024 22:02
@anaPerezGhiglia anaPerezGhiglia marked this pull request as ready for review June 27, 2024 22:11
@@ -206,18 +214,14 @@ impl<'b, B: BlackBoxFunctionSolver<F>, F: AcirField> BrilligSolver<'b, F, B> {
}))
}
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if it doesn't throw you into borrow checker hell, maybe it's a good idea to move the left hand side of let payload = ... to a function, for readability

})
.collect(),
call_stack,
found_trap,

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Having a boolean capture this doesn't feel right, have you considered just adding the FailureReason here? (so instead of found_trap: bool, you'd end up with reason: FailureReason)

@anaPerezGhiglia anaPerezGhiglia force-pushed the fix/debugger-brillig-assertion-fail branch from a322e9c to d47f33c Compare June 28, 2024 21:08
@anaPerezGhiglia anaPerezGhiglia force-pushed the fix/debugger-on-assertion-failure branch from 58e8fb4 to 370a610 Compare June 28, 2024 21:09
@anaPerezGhiglia
Copy link
Member Author

Closing this PR in favor of #6

@anaPerezGhiglia anaPerezGhiglia deleted the fix/debugger-on-assertion-failure branch July 3, 2024 17:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants